#include "cinterface.h"

CInterface::CInterface(QObject *parent) :
    QObject(parent)
{
    CryptMethod=0;
    MessageCrypted=0;
}

QString CInterface::GetKey () const
{
    return Key;
}
QRgb CInterface::GetPixel (int x, int y) const
{
    return Image.pixel (x,y);
}
int CInterface::GetHeight () const
{
    return Image.height ();
}
int CInterface::GetWidth () const
{
    return Image.width ();
}

bool CInterface::SetPixel (int x, int y, QRgb color)
{
    if(x<0||y<0)
    {
        return 0;
    }
    Image.setPixel (x,y,color);
    return 1;
}
bool CInterface::SetKey (QString NewKey)
{
    if(NewKey.isEmpty ()) return 0;
    Key=NewKey;
    return 1;
}

QString CInterface::GetMessage () const
{
    return Message;
}
bool CInterface::SetMessage (QString NewMessage)
{
    if(NewMessage.isEmpty ())
    {
        return 0;
    }
    Message=NewMessage;
    MessageCrypted=1;
    return 1;
}
bool CInterface::IsMassageCrypted () const
{
    return MessageCrypted;
}
QPixmap CInterface::GetImage ()
{
    return QPixmap::fromImage (Image);
}

bool CInterface::LoadData (CInput *in)
{
    Message=in->GetMessage ();
    Key=in->GetKey ();
    Image=in->GetImage ();
    return 1;
}
